//
//  BYTableViewCell.m
//  ZhiHuiLiJiang
//
//  Created by Work on 2018/12/17.
//  Copyright © 2018年 WisdomLijiang. All rights reserved.
//导览页和搜索页tabviewcell

#import "BYTableViewCell.h"

@implementation BYTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addView];
    }
    return self;
}
-(void)addView{
    [self.contentView addSubview:self.heardImageView];
    [self.heardImageView addSubview:self.tagLabel];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.redTagrightLabel];
    [self.contentView addSubview:self.contentLabel];
    [self.heardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(BY_Width(24));
        make.top.equalTo(self.contentView.mas_top).offset(BY_Height(20));
        make.size.mas_equalTo(CGSizeMake(BY_Width(248), BY_Width(164)));
    }];
    [self.tagLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.heardImageView.mas_right).offset(BY_Width(-10));
        make.bottom.equalTo(self.heardImageView.mas_bottom).offset(BY_Width(-10));
        make.size.mas_equalTo(CGSizeMake(30, 20));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.heardImageView.mas_top).offset(BY_Height(5));
        make.left.equalTo(self.heardImageView.mas_right).offset(BY_Width(32));
        make.right.equalTo(self.contentView.mas_right).offset(BY_Width(-24));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.titleLabel.mas_bottom).offset(BY_Height(12));
        make.right.equalTo(self.redTagrightLabel.mas_right);
    }];
    [self.redTagrightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentLabel.mas_left);
        make.top.equalTo(self.contentLabel.mas_bottom).offset(BY_Height(8));
        make.right.equalTo(self.contentView.mas_right).offset(BY_Width(-24));
    }];
}
-(UIImageView *)heardImageView{
    if (!_heardImageView) {
        _heardImageView = [[UIImageView alloc]init];
        _heardImageView.layer.masksToBounds = YES;
        _heardImageView.layer.cornerRadius = 5;
    }
    return _heardImageView;
}
-(UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = RGBA(0, 0, 0, 0.9);
        _titleLabel.font  = BYPTFont34;
        [_contentLabel sizeToFit];
    }
    return _titleLabel;
}
-(UILabel *)tagLabel{
    if (!_tagLabel) {
        _tagLabel = [[UILabel alloc]init];
        _tagLabel.backgroundColor = RGBA(0, 0, 0, 0.5);
        _tagLabel.textColor = RGBA(255, 255, 255, 1);
        _tagLabel.layer.masksToBounds = YES;
        _tagLabel.hidden = YES;
        _tagLabel.layer.cornerRadius = 10;
        _tagLabel.font = BYPTFont22;
        _tagLabel.textAlignment =NSTextAlignmentCenter;
    }
    return _tagLabel;
}
-(UILabel *)redTagrightLabel{
    if (!_redTagrightLabel) {
        _redTagrightLabel = [[UILabel alloc]init];
        _redTagrightLabel.textColor =RGBA(88, 88, 88, 1);
        _redTagrightLabel.font = BYPTFont22;
        _redTagrightLabel.numberOfLines = 0;
        [_redTagrightLabel sizeToFit];
    }
    return _redTagrightLabel;
}
-(UILabel *)contentLabel{
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc]init];
        _contentLabel.textColor =RGBA(0, 0, 0, 0.58);
        _contentLabel.font = BYPTFont24;
        _contentLabel.numberOfLines = 2;
        [_contentLabel sizeToFit];
    }
    return _contentLabel;
}
-(void)setBYcitizenModel:(BYcitizenModel *)model{
    
    [self.heardImageView sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:[UIImage imageNamed:@""]];
    self.tagLabel.text = model.tag;
    self.titleLabel.text = model.title;
    self.redTagrightLabel.text = [NSString stringWithFormat:@"来源: %@  作者: %@",model.origin,model.author];
    self.contentLabel.text = model.intro;
    //    _author    __NSCFString *    @"张岚"    0x000060000042f920
    //    _category    NSTaggedPointerString *    @"0"    0xa000000000000301
    //    _intro    __NSCFString *    @"丽江古城→狮子山→木府→丽江四方街→冰川公园→云杉坪→蓝月谷→束河古镇→束河四方街→青龙桥→九鼎龙潭→三圣宫→茶马古道博物馆→拉市海湿地公园"    0x00006000003442b0
    //    _material_uid    NSTaggedPointerString *    @"731"    0xa000000003133373
    //    _order    NSTaggedPointerString *    @"0"    0xa000000000000301
    //    _origin    __NSCFString *    @"丽江旅游"    0x0000600000427c40
    //    _status    NSTaggedPointerString *    @"1"    0xa000000000000311
    //    _tag    __NSCFConstantString *    @""    0x000000010b343320
    //    _time    __NSCFConstantString *    @""    0x000000010b343320
    //    _title    __NSCFString *    @"丽江+玉龙雪山4日玩法"    0x0000600000252ba0
    //    _cover    __NSCFString *    @"http://p3-q.mafengwo.net/s10/M00/4F/6B/wKgBZ1lsKMqAKOaFAAEFhyx18Iw281.png"    0x00006000002a69c0
}


@end

